<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="../js/vue.min.js"></script>
</head>
<style>
body{
	background: #ebebeb;
	font-family: "Helvetica Neue","Hiragino Sans GB","Microsoft YaHei","\9ED1\4F53",Arial,sans-serif;
	color: #222;
	font-size: 12px;
}
*{padding: 0px;margin: 0px;}
.top_div{
	background: #008ead;
	width: 100%;
	height: 400px;
}
.ipt{
	border: 1px solid #d3d3d3;
	padding: 10px 10px;
	width: 290px;
	border-radius: 4px;
	padding-left: 35px;
	-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
	box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
	-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
	-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
	transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s
}
.ipt:focus{
	border-color: #66afe9;
	outline: 0;
	-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);
	box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)
}
.u_logo{
	background: url("../assets/images/username.png") no-repeat;
	padding: 10px 10px;
	position: absolute;
	top: 43px;
	left: 40px;

}
.p_logo{
	background: url("../assets/images/password.png") no-repeat;
	padding: 10px 10px;
	position: absolute;
	top: 12px;
	left: 40px;
}
a{
	text-decoration: none;
}
.tou{
	background: url("../assets/images/tou.png") no-repeat;
	width: 97px;
	height: 92px;
	position: absolute;
	top: -87px;
	left: 140px;
}
.left_hand{
	background: url("../assets/images/left_hand.png") no-repeat;
	width: 32px;
	height: 37px;
	position: absolute;
	top: -38px;
	left: 150px;
}
.right_hand{
	background: url("../assets/images/right_hand.png") no-repeat;
	width: 32px;
	height: 37px;
	position: absolute;
	top: -38px;
	right: -64px;
}
.initial_left_hand{
	background: url("../assets/images/hand.png") no-repeat;
	width: 30px;
	height: 20px;
	position: absolute;
	top: -12px;
	left: 100px;
}
.initial_right_hand{
	background: url("../assets/images/hand.png") no-repeat;
	width: 30px;
	height: 20px;
	position: absolute;
	top: -12px;
	right: -112px;
}
.left_handing{
	background: url("../assets/images/left-handing.png") no-repeat;
	width: 30px;
	height: 20px;
	position: absolute;
	top: -24px;
	left: 139px;
}
.right_handinging{
	background: url("../assets/images/right_handing.png") no-repeat;
	width: 30px;
	height: 20px;
	position: absolute;
	top: -21px;
	left: 210px;
}
.top{
	background: rgb(255, 255, 255); 
	margin: -100px auto auto; 
	border: 1px solid rgb(231, 231, 231); 
	border-image: none; 
	width: 400px; 
	height: 200px; 
	text-align: center;
}
.box{
	width: 165px; 
	height: 96px; 
	position: absolute;
}
.input_1{
	padding: 30px 0px 10px; 
	position: relative;
}
.line{
	height: 50px; 
	line-height: 50px; 
	margin-top: 30px; 
	border-top-color: rgb(231, 231, 231); 
	border-top-width: 1px; 
	border-top-style: solid;
}
.cl{
	color: rgb(204, 204, 204);
}
.fl{
	float: left;
}
.fr{
	float: right;
}
.mr10{
	margin-right: 10px;
}
.log{
	background: rgb(0, 142, 173); 
	padding: 7px 10px; 
	border-radius: 4px; 
	border: 1px solid rgb(26, 117, 152); 
	border-image: none; 
	color: rgb(255, 255, 255); 
	font-weight: bold;
}
</style>

<body>
	<div id="app">
		<div class="top_div"></div>
		<div class="top">
			<div class="box">
				<div class="tou"></div>
				<div class="initial_left_hand" id="left_hand"></div>
				<div class="initial_right_hand" id="right_hand"></div>
			</div>
			<p class="input_1">
				<span class="u_logo"></span>
				<input type="text" class="ipt" name="user" placeholder="请输入用户名或邮箱" v-model="userName"></input>
			</p>
			<p style="position: relative;">
				<span class="p_logo"></span>
				<input class="ipt" name="password" type="password" v-model="password" placeholder="请输入密码"></input>
			</p>
			<div class="line">
				<p style="margin: 0px 35px 20px 45px;">
					<span class="fl">
						<a href="#" class="cl">忘记密码?</a>
					</span>
					<span class="fr">
						<a href="#" class="cl mr10">注册</a>
						<button class="log" @click="login()">登录</button>
					</span>
				</p>
			</div>
		</div>
	</div>

</body>
<script>
	var vm=new Vue({
		el:"#app",
		data(){
			return {
				userName:'',
				password:'',
				rememberPassword:''
			}
		},
		mounted(){ 
   			if(this.$cookie.get('sessionID')){ 
   		const that = this; 
        this.$http.get( 
         	that.surl+'checkLogin?sessionID='+that.$cookie.get('sessionID') 
         ) 
           .then(function (response) { 
           	console.log(response.data); 
           	if(response.data===true){ 
 			  that.$router.push('/admin/home'); 
           	} 
           }) 

		 
           .catch(function (error) { 
             that.$router.push('/admin/404'); 
           }); 
   	} 
   }, 
   methods:{ 
   	login () { 
   		if(this.user!==''&&this.password!==''){ 
 	  		const that = this; 
 	  		this.$http.get(	 
 	        	that.surl+'login?userName='+that.userName+'&password='+that.password 
 	        ) 
 	        .then(function (response) { 
 	          	if(response.data){ 
 	          		if(that.rememberPassword){ 
 	          			that.$cookie.set('sessionID',response.data, { expires: '7D' }); 
 	          		}else{ 
 	          			that.$cookie.set('sessionID',response.data); 
 	          		} 
 				    that.$router.push('/admin/home'); 
 	          	}else{ 
 	          		const title = '用户名或密码错误'; 
 			    	const content = '<p>请输入正确的用户名和密码</p>'; 
 				    that.$Modal.error({ 
 					    title: title, 
 					    content: content 
 				    }); 
 	          	} 
 	          }) 
             .catch(function (err) { 
             	that.$router.push('/admin/404'); 
             }); 
 	    }else{ 
 	    	const title = '信息不完整'; 
 	    	const content = '<p>请输入正确的用户名和密码</p>'; 
 		    this.$Modal.warning({ 
 			    title: title, 
 			    content: content 
		    }); 
 	    } 
   	} 
   } 
 } 

</script>
</html>